package com.gin.retrofit.factory

import retrofit2.Converter
import retrofit2.Retrofit
import java.lang.reflect.Type

/**
 *
 * @author bx002
 * @since 2024/2/21 17:49
 */
class QueryParameterConverterFactory : Converter.Factory() {
    override fun stringConverter(
        type: Type,
        annotations: Array<out Annotation>,
        retrofit: Retrofit,
    ): Converter<*, String>? {
        if (type is Class<*> && type.interfaces.any { clazz -> clazz == QueryParameter::class.java }) {
            return QueryParameterConverter()
        }
        return super.stringConverter(type, annotations, retrofit)
    }
}